
package com.jf.cloud.multishop.service;

import com.jf.cloud.api.multishop.bo.OrderChangeShopWalletAmountBO;
import com.jf.cloud.api.multishop.bo.ShopWalletBO;
import com.jf.cloud.api.user.bo.RechargeNotifyBO;
import com.jf.cloud.common.database.dto.PageDTO;
import com.jf.cloud.common.database.vo.PageVO;
import com.jf.cloud.common.order.bo.PayNotifyBO;
import com.jf.cloud.common.order.vo.OrderSimpleAmountInfoBO;
import com.jf.cloud.multishop.dto.ShopWalletLogSearchDTO;
import com.jf.cloud.multishop.model.ShopWallet;
import com.jf.cloud.multishop.vo.ShopWalletVO;

import java.util.List;
import java.util.Map;

/**
 * 商家钱包信息
 *
 * @author zz
 * @date 2021-01-07 16:41:03
 */
public interface ShopWalletService {

    /**
     * 保存商家钱包信息
     * @param shopWallet 商家钱包信息
     */
    void save(ShopWallet shopWallet);

    /**
     * 更新商家钱包信息
     * @param shopWallet 商家钱包信息
     */
    void update(ShopWallet shopWallet);

    /**
     * 通过下单添加商家待结算金额，确认收货后进行结算
     * @param orderSimpleAmountInfos 订单id和店铺id关联信息
     * @param message 订单id和店铺id关联信息
     * @param settledAmountMap 店铺已结算金额map
     * @param salesMap 商家的代销配置
     */
    void addAmountByOrder(List<OrderSimpleAmountInfoBO> orderSimpleAmountInfos, PayNotifyBO message, Map<Long, Long> settledAmountMap, Map<Long, Integer> salesMap);

    /**
     * 结算给商家增加结算金额
     * @param orderId 订单id
     */
    void addAmountBySettledOrder(Long orderId);


//    /**
//     * 通过退款，减少商家钱包金额
//     * @param refundId
//     * @return
//     */
//    void subShopAmountByRefund(Long refundId);

    /**
     * 通过退款，锁定商家钱包金额
     * @param orderChangeShopWalletAmountBO 金额相关信息
     * @return
     */
    void refundShopAmountByRefund(OrderChangeShopWalletAmountBO orderChangeShopWalletAmountBO);

    /**
     * 通过退款，锁定商家钱包金额，待采购
     * @param orderChangeShopWalletAmountBO 金额相关信息
     * @return
     */
    void refundShopAmountByRefundAndWaitPur(OrderChangeShopWalletAmountBO orderChangeShopWalletAmountBO);

//    /**
//     * 解锁店铺钱包
//     * @param refundId
//     */
//    void unlockShopAmountByRefund(Long refundId);

    /**
     * 根据店铺id查询店铺钱包信息
     * @param shopId 店铺id
     * @return 店铺钱包信息
     */
    ShopWalletVO getByShopId(Long shopId);

    /**
     * 获取所有店铺的钱包信息
     * @param shopWalletLogSearchDTO
     * @return 钱包信息
     */
    ShopWalletVO getAllShop(ShopWalletLogSearchDTO shopWalletLogSearchDTO);

    /**
     * 分页获取店铺钱包信息
     * @param pageDTO
     * @param shopWalletLogSearchDTO
     * @return
     */
    PageVO<ShopWalletVO> pageShopWalletByTime(PageDTO pageDTO, ShopWalletLogSearchDTO shopWalletLogSearchDTO);

    /**
     * 订单部分退款导致订单关闭 商家结算操作
     * @param orderChangeShopWalletAmountBO 金额相关信息
     */
    void settlementShopAmountByRefund(OrderChangeShopWalletAmountBO orderChangeShopWalletAmountBO);

    /**
     * 订单超时未支付尾款 商家结算操作
     * @param orderChangeShopWalletAmountBO 金额相关信息
     */
    void settlementShopAmountByPreSaleFail(OrderChangeShopWalletAmountBO orderChangeShopWalletAmountBO);

    /**
     * 订单部分退款导致订单关闭 商家结算操作,待采购时的金额处理
     * @param orderChangeShopWalletAmountBO 金额相关信息
     */
    void settlementShopAmountByRefundAndWaitPur(OrderChangeShopWalletAmountBO orderChangeShopWalletAmountBO);

    /**
     * 修改店铺钱包的待结算金额
     * @param message 分销产生的待结算金额
     */
    void updateByDistributionAmount(List<ShopWalletBO> message);

    /**
     * 根据店铺ids获取商家钱包信息列表
     * @param shopIds 店铺ids
     * @return 商家钱包信息列表
     */
    List<ShopWalletVO> listByShopIds(List<Long> shopIds);

    /**
     * 获取店铺余额
     * @param shopId 店铺id
     * @return
     */
    Long getSettlementAmountByShopId(Long shopId);

    /**
     * 充值成功
     * @param message
     */
    void rechargeSuccess(RechargeNotifyBO message);

    /**
     * 商家减少结算金额
     * @param shopId
     * @param changeAmount
     * @return
     */
    boolean subSettledAmount(Long shopId, Long changeAmount);

    List<Map<String,Object>> shop_wallet_by_area(Long areaId,Integer level);
}
